package com.artifact.services.impl;

import java.util.Date;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.artifact.dao.AdminDao;
import com.artifact.dao.SoftInfoDao;
import com.artifact.model.Admin;
import com.artifact.services.IndexActionServices;

@Service("indexActionServices")
public class IndexActionServicesImpl implements IndexActionServices {
	private AdminDao adminDao;
	private SoftInfoDao softInfoDao;

	@Resource(name = "adminDao")
	public void setAdminDao(AdminDao adminDao) {
		this.adminDao = adminDao;
	}

	@Resource(name = "softInfoDao")
	public void setSoftInfoDao(SoftInfoDao softInfoDao) {
		this.softInfoDao = softInfoDao;
	}

	@Override
	public Admin login(String userAccount, String userPassword) {
		Admin user = adminDao.getAdmin(userAccount, userPassword);
		if (user != null) {
			adminDao.AdminLogin(userAccount, new Date());
		}
		return user;
	}

	public String getDownloadUrl(String name) {
		return softInfoDao.getSoftInfo(name).getValue();
	}
}
